package edu.msse.signup.ui;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import org.apache.commons.lang.math.NumberUtils;

public class FacesApplicationService implements ApplicationService {

	public void addErrorMessage(String message) {
	    addErrorMessage(null, message);
	}

	public void addErrorMessage(String clientId, String message) {
	    FacesContext faces = FacesContext.getCurrentInstance();
	    faces.addMessage(clientId, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
	}

	public void addInfoMessage(String message) {
	    FacesContext faces = FacesContext.getCurrentInstance();
	    faces.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, message, message));
	}

	public boolean validateNumber(String id){
		if (!NumberUtils.isNumber(id))
		{
			addErrorMessage("Number of Volunteers value must be a number.");
			return false;
		}
		
		return true;
	}

}

